import { Catch } from '@midwayjs/decorator';
import { Context } from '@midwayjs/koa';
import { BadRequestError } from '../error/request.error';

@Catch(BadRequestError)
export class BadRequestErrorFilter {
  async catch(err: BadRequestError, ctx: Context) {
    const message = err.message;
    ctx.status = 400;
    return {
      code: 400,
      message,
    };
  }
}
